#include <iostream>
#include <algorithm>
#include <cstdio>
#include <array>
using namespace std;
#ifdef ONLINE_JUDGE

#define getchar() (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1 << 21, stdin), p1 == p2) ? EOF : *p1++)
char buf[1 << 23], *p1 = buf, *p2 = buf, ubuf[1 << 23], *u = ubuf;

#endif
int read() {
    int p = 0, flg = 1;
    char c = getchar();
    while (c < '0' || c > '9') {
        if (c == '-') flg = -1;
        c = getchar();
    }
    while (c >= '0' && c <= '9') {
        p = p * 10 + c - '0';
        c = getchar();
    }
    return p * flg;
}
void write(int x) {
    if (x < 0) {
        x = -x;
        putchar('-');
    }
    if (x > 9) {
        write(x / 10);
    }
    putchar(x % 10 + '0');
}
bool _stmer;

const int N = 1e6 + 5, M = 2e6 + 5;

namespace G {

array <int, N> fir;
array <int, M> nex, to;

int cnt = 1;
void add(int x, int y) {
    cnt++;
    nex[cnt] = fir[x];
    to[cnt] = y;
    fir[x] = cnt;
}

} //namespace G

array <int, N> fa, dep;

int dfs(int x, int k) {
    int ans = 0; dep[x] = 1;
    for (int i = G::fir[x]; i; i = G::nex[i]) {
        ans += dfs(G::to[i], k);
        dep[x] = max(dep[x], dep[G::to[i]] + 1);
    }
    if (dep[x] >= k && fa[x] != 1) ans++, dep[x] = 0;
    return ans;
}

bool _edmer;
int main() {
    cerr << (&_stmer - &_edmer) / 1024.0 / 1024.0 << "MB\n";
#ifndef cxqghzj
    freopen("lost.in", "r", stdin);
    freopen("lost.out", "w", stdout);
#endif
    int n = read(), k = read();
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        fa[i] = read();
        if (i > 1)
            G::add(fa[i], i);
    }
    if (fa[1] != 1) ans++;
    fa[1] = 1;
    write(dfs(1, k) + ans), puts("");
    return 0;
}
